﻿using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;

namespace ViewModel.Inventory
{
    public class SectionViewModel : SectionWorkspaceViewModel
    {

        public SectionViewModel(MainWindowViewModel mainWindowViewModel)
        {
            if (mainWindowViewModel == null) throw new ArgumentNullException();

            this.MainWindowViewModel = mainWindowViewModel;
        }

        public override ReadOnlyCollection<CommandViewModel> Commands
        {
            get
            {
                if (_commands == null)
                {
                    _commands = new ReadOnlyCollection<CommandViewModel>(CreateFeatureCommands());
                }
                return _commands;
            }
        }

        List<CommandViewModel> CreateFeatureCommands()
        {
            return new List<CommandViewModel>
                       {
                           new CommandViewModel("Inventory Items", new RelayCommand(param => ShowInventoryItemsList())),
                           new CommandViewModel("Collections", new RelayCommand(param => ShowCollectionItemsList()))
                       };
        }


        private CollectionsListViewModel _inventoryCollectionsListViewModel;

        private void ShowCollectionItemsList()
        {
            if (_inventoryCollectionsListViewModel == null)
            {
                _inventoryCollectionsListViewModel = new CollectionsListViewModel();
            }
            MainWindowViewModel.ShowWorkspace(_inventoryCollectionsListViewModel);
        }

        private ItemsListViewModel _inventoryItemsListViewModel;

        private void ShowInventoryItemsList()
        {
            if(_inventoryItemsListViewModel == null)
            {
                _inventoryItemsListViewModel = new ItemsListViewModel();
            }
            MainWindowViewModel.ShowWorkspace(_inventoryItemsListViewModel);
        }

    }
}